package com.netstar.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.widget.ImageView;

import com.netstar.R;
import com.netstar.ui.BaseActivity;
import com.netstar.util.EvtLog;

/**
 * 开场动画
 * 
 * @author zou.sq
 */
public class LoadingActivity extends BaseActivity implements AnimationListener {

    private static final String TAG = "LoadingActivity";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EvtLog.d(TAG, "onCreate");
        setContentView(R.layout.loading_layout);
        loadAnimation();
    }

    private void loadAnimation() {
        ImageView mIvSplash = (ImageView) findViewById(R.id.iv_splash);
        // 创建透明度动画，效果为完全不透明到完全透明
        AlphaAnimation animation = new AlphaAnimation(0.1f, 1.0f);
        // 设置动画持续时间
        animation.setDuration(6000);
        // 启动动画，用ImageView作为动画载体
        mIvSplash.startAnimation(animation);
        // 监听动画的完成事件，在动画的完成事件中跳转到主界面
        animation.setAnimationListener(this);
    }

    @Override
    public void onAnimationStart(Animation animation) {
    }

    @Override
    public void onAnimationEnd(Animation animation) {
        Intent intent = new Intent(this, NetStarActivity.class);
        startActivity(intent);
        finish();
    }

    @Override
    public void onAnimationRepeat(Animation animation) {
    }
}
